/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entite;

import connexion.Connexion;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author asall
 */
public class Personnel {
        public String numhar;
        public String nom;
        public String prenom;
        
        static Connexion con= new Connexion();    
        
        public Personnel(){}
        public Personnel(String num, String nom, String prenom){
            this.nom=nom;
            this.numhar=num;
            this.prenom=prenom;
        }
        public String getNom(int idDiplome) {
		String res="nom du responsable";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select per.nom"
                                + " from diplome di, personnel per"
                                + " where di.fid_resp=per.id_pers and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("nom"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	} 
     public String getPrenom(int idDiplome) {
		String res="prenom du responsable";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select per.prenom"
                                + " from diplome di, personnel per"
                                + " where di.fid_resp=per.id_pers and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("prenom"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     
     public String getNumHarpege(int idDiplome) {
		String res="num harpege";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select per.num_harpege"
                                + " from diplome di, personnel per"
                                + " where di.fid_resp=per.id_pers and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("num_harpege"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     
     public String getCodeUfr(int idDiplome) {
		String res="code ufr";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select cp.code_apogee"
                                + " from diplome di, personnel per,composante cp"
                                + " where di.fid_resp=per.id_pers and"
                                + " per.fid_comp=cp.id_comp and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("code_apogee"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     
     public String getLibelle(int idDiplome) {
		String res="libelle ufr";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select cp.libelle_long"
                                + " from diplome di, personnel per,composante cp"
                                + " where di.fid_resp=per.id_pers and"
                                + " per.fid_comp=cp.id_comp and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_long"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}  
     public String getLibelleCourt(int idDiplome) {
		String res="libelle-court ufr";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select cp.libelle_court"
                                + " from diplome di, personnel per,composante cp"
                                + " where di.fid_resp=per.id_pers and"
                                + " per.fid_comp=cp.id_comp and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_court"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}  
     
     public static Personnel responsableParcours(int idParcours){
             String num="num responsable" ;
             String nom="nom responsable";
             String prenom="prenom responsable";
         Personnel per= new Personnel(num, nom, prenom);
     try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select per.num_harpege, per.nom, per.prenom"
                                + " from parcours_specialite par, personnel per"
                                + " where par.fid_responsable=per.id_pers and"
                                + " par.id_parc_adm= "+ idParcours );

			while (resultatDest.next()) {
				 num =(resultatDest.getString("num_harpege"));
				 nom=(resultatDest.getString("nom"));
                                 prenom=(resultatDest.getString("prenom"));
                                 per= new Personnel(num, nom, prenom);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return per;
     }
}
